#include<iostream>
using namespace std;

class Book; 
class CD;
class LibraryItemInterface; 

class LibraryVisitor {
	public:
		//virtual void visit(Book *)=0;
		//virtual void visit(CD *)=0;
		virtual void visit(LibraryItemInterface *)=0;
};

class LibraryItemInterface{
	public:
		void Access(LibraryVisitor *pl){
			pl->visit(this);
		}
		virtual void Do()=0;
}; 

class Book:public LibraryItemInterface{
	public:
		/*void Access(LibraryVisitor * pl){
			pl->visit(this);
		}*/
		void Do(){
			cout<<"Book.Do~"<<endl;
		}
};

class CD:public LibraryItemInterface{
	public:
		/*void Access(LibraryVisitor * pl){
			pl->visit(this);
		}*/
		void Do(){
			cout<<"CD.Do~"<<endl;
		}
};

class LSPN:public LibraryVisitor {
	public:
		/*void visit (Book *t){
			t->Do();
		}
		void visit (CD *t){
			t->Do();
		}*/
		void visit (LibraryItemInterface *t){
			t->Do();
		}
};

int main(void){
	LibraryItemInterface *pB=new Book();
	LibraryItemInterface *pC=new CD();
	LibraryVisitor *pV=new LSPN();
	pB->Access(pV);
	pC->Access(pV);
	
	delete pB;
	delete pC;
	delete pV;
	return 0;
}
